<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
	<script>
	function People(name,age){
		this.name=name
		this.age=age
	}	
	
	People.prototype.say=function(){
		console.log('say.......')
	}
	var p1=new People('李磊',12);
	console.log(p1);	
	p1.say();
	
	class Animal{
		constructor(name,color) {
		    this.name=name;
			this.color=color;
		}
		play(){
			console.log('play.....')
		}
	  static eat(){  
			console.log('eat....')
		}
		sleep(){
			console.log('sleep....')
		}
		
	}
	// Animal.count=100;
	var bird=new Animal('黄鹂','yellow');
	console.log(bird.name,bird.color);
	bird.play();
	//静态方法要用类名去调用
    Animal.eat();		
	//console.log(Animal.count);	
		
		//子类（派生类）会继承父类（基类）所有的方法和属性
	class Dog extends Animal{
		constructor(name,color,big) {
			super() //显示的调用一下super
		    this.name=name;
			this.color=color;
			this.big=big;
			
		}
		
		
		
		
		sleep(){
			console.log('呼呼的睡')
		}
	}	
	
	//var alpha=new Dog('二哈','灰白色')	
	var alpha=new Dog('金毛','金色','big')
	console.log(alpha.name)
	alpha.play();
	//如果子类和父类定义了同一个方法，子类会重写父类的方法
	alpha.sleep();	
		
	
		
		
	</script>	
	</body>
</html>
